
# 运算符
# 两个向量相加
v <- c(3,4,5);
t <- c(6,7,8);
cat("v + t = ",v+t,"
");

# 两个向量相减
v <- c(7,8,9);
t <- c(4,5,6);
cat("v - t = ",v-t,"
");

# 两个向量相乘
v <- c(4,5,6);
t <- c(7,8,9);
cat("v * t = ",v*t,"
");

# 两个向量相除
v <- c(9,12,18);
t <- c(3,6,9);
cat("v / t = ",v/t,"
");

# 两个向量求余
v <- c(11,23,17);
t <- c(4,8,10);
cat("v/t 取余:",v%%t,"
");

# 两个向量求商
cat("v/t 取商:",v%/%t,"
");

# 向量的指数运算
cat("v^t 指数:",v^t,"
");


# 关系运算符
v <- c(2,5.5,6,9);
t <- c(8,2.5,15,9);

#判断关系
cat("v > t:",v>t,"
"); 

cat("v < t :",v<t,"
");
cat("v == t",v==t,"
");

# 逻辑运算符
# 和(&)关系
v <- c(3,1,TRUE,2+3i);
t <- c(4,1,FALSE,2+3i)
cat("v & t:",v&t,"
");

# 与(|)关系
cat("v | t:",v|t,"
");

# 非(!)关系
cat("! v:",!v,"
");

# 其他运算符
# (:)应用
v <- 2:8;
cat("2:8->",v,"
");

# (%in%)应用
x <- 6;
cat("x in v:",x %in% v,"
" );

# 矩阵的转置乘法
M =  matrix(c(4,5,6,7,8,9,10),nrow=2,ncol=3,byrow=TRUE);
R = M %*% t(M);
print( R );
# cat("M * t(M) = ",R,"
# ");